﻿
@{
    ViewData["Title"] = "重置密码";
    Layout = "~/Areas/WX/Views/Shared/_Layout.cshtml";
}

@section Tops{
    <style>
        .backg {
            background: #F4F5F6;
        }
    </style>
}

<header class="hui-header">
    <div id="hui-back"></div>
    <h1>重置密码</h1>
</header>
<div class="hui-wrap" id="form1" method="post">
    <div class="hui-center-title" style="margin-top:35px;"><h1 style="border:0px;">输入新密码</h1></div>
    <div style="margin:20px 10px; margin-bottom:15px;" class="hui-form" id="form1">

        <div class="hui-form-items">
            <div class="hui-form-items-title">登录密码</div>
            <input type="password" class="hui-input hui-pwd-eye" name="pwd" placeholder="登录密码" checkType="string" id="pwd" checkData="6,20" checkMsg="密码应为6-20个字符" />
        </div>
        <div class="hui-form-items">
            <div class="hui-form-items-title">确认密码</div>
            <input type="password" class="hui-input hui-pwd-eye" name="pwdc" placeholder="确认密码" checkType="sameWithId" checkData="pwd" checkMsg="两次密码不一致" />
        </div>

    </div>
    <div style="padding:10px; padding-top:10px;">
        <button type="button" class="hui-button hui-button-large hui-primary" id="submit">立即找回</button>
    </div>
</div>


@section Scripts{
    <script src="~/HUI-master/js/hui-form.js"></script>
    <script>
        function gotoHome() {
            window.location.href = '/WX/Account/ForgotPassword'
        }
        hui('#submit').click(function () {
            var data = hui.getFormData('#form1');
            var username = localStorage.getItem('username');
           console.log(data)
           hui.post(
               '/WX/Account/ChangePassword',
               { pwd: data.pwd, pwdc: data.pwdc, username: username},
                    function (msg) {
                        if (msg == 'ok') {
                            localStorage.removeItem('username');
                            hui.alert('密码修改成功', '好的', function () { window.location.href = '/WX/Account/Login' });
                        } else {
                            hui.alert(msg, '修改', function () {  });
                        }
                    },
                    function (e) {
                        hui.iconToast('读取消息失败', 'warn');
                    }
                );

        });
    </script>
}


